<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class HomeCommentController extends Controller
{
	//列表
    public function getIndex($id)
    {   
      
        return view('Home.comment.add',['dingdan_id'=>$id]);
    }

    //添加
    public function postAdd(Request $request)
    {
        //接收数据
        $data = $request->only(['content','dingdan_id']);
        //时间
        $data['time'] = date('Y-m-d H:i:s',time());
        //id
        $data['uid'] = session('id');
        //执行添加
        $res = DB::table('comment')->insert($data);
        //判断
        if($res){
            return redirect('/home/order/xiangqing')->with('success','评论成功');
        }else{
            return back()->with('error','评论失败');
        }
    }

}
